package csci5828.servlet;

import javax.servlet.ServletContext;

import csci5828.search.SearchResults;
import csci5828.tasks.TaskManager;
import csci5828.tasks.impl.TaskManagerImpl;

public class TaskManagerUtil {
	
	private static TaskManagerUtil instance;
	public TaskManager<String> taskManager;
	
	private TaskManagerUtil() {
		taskManager = new TaskManagerImpl<String>();
	}
	
	public static synchronized TaskManagerUtil getInstance() {
		if (instance == null) {
			instance = new TaskManagerUtil();
		}
		return instance;
	}
	
	@SuppressWarnings("unchecked")
	public static TaskManager<SearchResults> getSearchTaskManager(ServletContext ctxt) {
		// Get a handle to the global search task manager
		return (TaskManager<SearchResults>)ctxt.getAttribute(ContextAttributes.SEARCH_TASK_MANAGER);
	}
}
